package GUI;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.SystemColor;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextPane;
import javax.swing.BoxLayout;
import GUI.Controls.CloseButton;
import X.Exception.MonopolyException;

/**
 * 
 * Fehlermeldungsfenster.
 * 
 * @author 
 *
 *@version $Revision: 0.0$
 *
 */
public class GUIFehlerMeldung extends JDialog {
	
	private static final long serialVersionUID = -5628846602667645906L;
	private final JPanel contentPanel = new JPanel();
	private JTextPane textPane;

	/**
	 * Create the dialog.
	 */
	public GUIFehlerMeldung(MonopolyException ex){
		this();
		StringBuffer sb = new StringBuffer();
		this.setTitle(ex.GetMessageCode());
		sb.append(ex.getMessage());
		sb.append("\n\n");
		for(String value : ex){
			sb.append(value);
			sb.append("\n");
		}
		textPane.setText(sb.toString());
	}
	
	private GUIFehlerMeldung() {
		setBounds(100, 100, 450, 193);
		setModal(true);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.X_AXIS));
		{
			textPane = new JTextPane();
			textPane.setBackground(SystemColor.control);
			contentPanel.add(textPane);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new CloseButton(this, "OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
		}
	}

}
